﻿using System.Collections.Generic;
using Entitas;
class EnemyBattleDisengageSystem : ReactiveSystem<EnemyEntity>
{
    public EnemyBattleDisengageSystem(Contexts contexts) : base(contexts.enemy)
    {

    }

    protected override void Execute(List<EnemyEntity> entities)
    {
       foreach(var e in entities)
        {
            e.isRoaming = true;
            ServiceManager.DebugMessageService.Print("testing in " + ToString());
        }
    }

    protected override bool Filter(EnemyEntity entity)
    {
        if (entity.isBattleEngaged == false)
        {
            if (entity.hasPosition)
            {
                if (entity.position.value == entity.spawnPosition.value)
                    return true;
                else return false;
            }
          
            else return false;
        }
        else return false;
    }

    protected override ICollector<EnemyEntity> GetTrigger(IContext<EnemyEntity> context)
    {
        return context.CreateCollector(EnemyMatcher.Position.AddedOrRemoved());
    }

    public override string ToString()
    {
        return "Enemy Battle Disengage System";
    }
}
